package com.hzmall.util;

import javax.xml.ws.soap.Addressing;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class BigDecimalUtil {
    public static BigDecimal add(Double a1,Double a2){
        BigDecimal b1 = new BigDecimal(Double.toString(a1));
        BigDecimal b2 = new BigDecimal(Double.toString(a2));
        return b1.add(b2);
    }

    public static BigDecimal sub(Double a1, Double a2){
        BigDecimal b1 = new BigDecimal(Double.toString(a1));
        BigDecimal b2 = new BigDecimal(Double.toString(a2));
        return b1.subtract(b2);
    }

    public static BigDecimal mul(Double a1, Double a2){
        BigDecimal b1 = new BigDecimal(Double.toString(a1));
        BigDecimal b2 = new BigDecimal(Double.toString(a2));
        return b1.multiply(b2);
    }

    public static BigDecimal div(Double a1, Double a2) {
        BigDecimal b1 = new BigDecimal(Double.toString(a1));
        BigDecimal b2 = new BigDecimal(Double.toString(a1));
        return b1.divide(b2,2, RoundingMode.HALF_UP);
    }
}
